// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import Axios from 'axios'
import qs from 'qs'
import { Button, Select } from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css' //样式必须引入
import VueLazyload from 'vue-lazyload'

Vue.use(VueLazyload)
Vue.use(Button)
Vue.use(Select)
Vue.prototype.$axios = Axios
Vue.config.productionTip = false
// axios.defaults.baseURL="https://api.example.com";
// axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';


// 添加请求拦截器
// axios.interceptors.request.use(function (config) {
//   if(config.method == "post"){
//     config.data = qs.stringify(config.data)
//   }
//   console.log(config)
//   return config;
// }, function (error) {
//   // 对请求错误做些什么
//   return Promise.reject(error);
// });

// 添加响应拦截器
// axios.interceptors.response.use(function (response) {
//   // 对响应数据做点什么
//   return response;
// }, function (error) {
//   // 对响应错误做点什么
//   return Promise.reject(error);
// });

Vue.directive("focus", {
  inserted: function (el) {
    el.focus();
  }
})
/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  components: { App },
  template: '<App/>'
})
